package classloader;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;

/**
 * 类加载器 demo4
 * 加载本地磁盘class
 * @author dingwen
 * @date 2021/08/29
 */
public class ClassLoaderDemo4 {
    public static void main(String[] args) throws Exception {
        File file = new File("/Users/dingwen/Documents/study/java8-study/src/classloader/");
        URI uri = file.toURI();
        URL url = uri.toURL();
        URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{url});
        System.out.println("classLoader.getParent() = " + urlClassLoader.getParent());
        Class clazz = urlClassLoader.loadClass("classloader.URLClassLoaderDemo");
        clazz.newInstance();

        //classLoader.getParent() = sun.misc.Launcher$AppClassLoader@18b4aac2
        //URLClassLoaderDemo new instance


    }
}
